import { Component, OnInit, ViewEncapsulation,OnDestroy } from '@angular/core';
import { Utility } from '../../../publish/src/framework/core/utility';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { WorkerService } from '../../../publish/src/framework/core/worker-util';
// import {worker/}

@Component({
    templateUrl: 'entrance.component.html',
    styleUrls: ['entrance.component.scss'],
    providers:[WorkerService],
    encapsulation: ViewEncapsulation.None
})
export class EntranceComponent implements OnInit, OnDestroy {
    skin: any;
    menu_flag: Boolean;
    constructor(private route: ActivatedRoute,private router:Router,private worker:WorkerService ) {

        this.menu_flag = false;
    }

    ngOnInit() {

        this.route.queryParams.forEach((para: Params) => {
            this.skin = para['skin'];
            if (this.skin == null) this.skin = 'default';
        });

        // this.worker.timerRenovating(2000,1000,null);
        this.worker.timerRenovating(2000,1000,this.logNum,1,'one','two','three');


    }
    menuDis() {

        if (this.menu_flag) this.menu_flag = false;
        else this.menu_flag = true;

    }
    changeCol(e) {
        var id = e.target.id;
        if (id !== "") {
            this.router.navigate(['/entrance'], { queryParams: { 'skin': id } });
        }
    }

    private logNum(num:any, strone:any, strtwo:any, strthree:any){
        console.log(num);
        console.log(strone);
        console.log(strtwo);
        console.log(strthree);
    }

    ngOnDestroy(){
        this.worker.destroyTimer();
    }


}
